*** Do File to Replicate Tables and Figures in the Main Paper ***

clear
use "C:\Users\dmac9\Dropbox\PRQ Conditionally Accepted Trust and Inequality Manuscript\CANES 1984_to_2016 PRQ.dta"  

**Table 3 - Main Results**
reg rd3_factor01 c.top1##c.trust4_factor01 i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
partyid01 ideology01 egal4_factor01 ft_blacks01 ft_hispanics01 ft_poor01 ft_bigbusiness01 c.med_hhinc c.unemployment i.year i.state_fips , cluster(stateyear)

*Export to Latex*
outreg2 using canes_table3.tex, dec(3) replace sideway

**Figure 2 - Plotting Main Results**
margins, dydx(top1) at(trust4_factor01 =(0(.1)1))
marhis trust4_factor01, mar(top1) percent

**Figure 3 - Plotting Responsiveness to Inequality for People Low and High in Trust**

*Figure 3a - Low Political Trust*
margins, at(top1=9.4 trust4_factor01=.11) saving(m1a, replace)
margins, at(top1=12.6 trust4_factor01=.11) saving(m2a, replace)
margins, at(top1=18.1 trust4_factor01=.11) saving(m3a, replace)
margins, at(top1=23.6 trust4_factor01=.11) saving(m4a, replace)
margins, at(top1=34.4 trust4_factor01=.11) saving(m5a, replace)

*Plot the results*
combomarginsplot  m1a m2a m3a m4a m5a, /// 
labels("Minimum" "-1 SD" "Mean" "+1 SD" "Maximum")

*Figure 3b - High Political Trust*
margins, at(top1=9.4 trust4_factor01=.49) saving(m1b, replace)
margins, at(top1=12.6 trust4_factor01=.49) saving(m2b, replace)
margins, at(top1=18.1 trust4_factor01=.49) saving(m3b, replace)
margins, at(top1=23.6 trust4_factor01=.49) saving(m4b, replace)
margins, at(top1=34.4 trust4_factor01=.49) saving(m5b, replace)

*Plot the results*
combomarginsplot  m1b m2b m3b m4b m5b, /// 
labels("Minimum" "-1 SD" "Mean" "+1 SD" "Maximum")


**Table 4 - Among Liberals/Moderates**
reg rd3_factor01 c.top1##c.trust4_factor01 i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
partyid01 ideology01 egal4_factor01 ft_blacks01 ft_hispanics01 ft_poor01 ft_bigbusiness01 c.med_hhinc c.unemployment i.year i.state_fips if (ideology01 >=0 & ideology01<=.5), cluster(stateyear)

*Export to Latex*
outreg2 using canes_table4.tex, dec(3) replace sideway

**Table 4 - Among Conservatives**
reg rd3_factor01 c.top1##c.trust4_factor01 i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
partyid01 ideology01 egal4_factor01 ft_blacks01 ft_hispanics01 ft_poor01 ft_bigbusiness01 c.med_hhinc c.unemployment i.year i.state_fips if (ideology01 > .5 & ideology01<=1), cluster(stateyear)

*Export to Latex*
outreg2 using canes_table4.tex, dec(3) append sideway

**Table 5 - Among the Less Affluent**
reg rd3_factor01 c.top1##c.trust4_factor01 i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
partyid01 ideology01 egal4_factor01 ft_blacks01 ft_hispanics01 ft_poor01 ft_bigbusiness01 c.med_hhinc c.unemployment i.year i.state_fips if (income>=1 & income<4), cluster(stateyear)

*Export to Latex*
outreg2 using canes_table5.tex, dec(3) replace sideway

**Table 5 - Among the More Affluent**
reg rd3_factor01 c.top1##c.trust4_factor01 i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
partyid01 ideology01 egal4_factor01 ft_blacks01 ft_hispanics01 ft_poor01 ft_bigbusiness01 c.med_hhinc c.unemployment i.year i.state_fips if (income>=4 & income<=5), cluster(stateyear)

*Export to Latex*
outreg2 using canes_table5.tex, dec(3) append sideway

**Table 6 - Alternative Moderators**
reg rd3_factor01 c.top1##c.trust4_factor01 c.top1##c.ft_blacks01 c.top1##c.ft_hispanics01 c.top1##c.ft_poor01 c.top1##c.ft_bigbusiness01 ///
i.age_group i.income i.educ3 female white married own_home union_hh unemployed ///
c.top1##c.partyid01 c.top1##c.ideology01 c.top1##c.egal4_factor01 c.med_hhinc c.unemployment i.year i.state_fips, cluster(stateyear)

*Export to Latex*
outreg2 using canes_table6.tex, dec(3) replace sideway

